package com.situ.team5.kzq.power.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.team5.kzq.power.service.JsService;
import com.situ.team5.kzq.power.service.QxService;
import com.situ.team5.kzq.recruit.service.EngageResumeService;
import com.situ.team5.kzq.recruit.service.SalaryGrantDetailsService;
import com.situ.team5.pojo.ConfigMajor;
import com.situ.team5.pojo.ConfigMajorKind;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@Controller
public class JsController {
@Autowired
    JsService jsser;
@Autowired
    QxService qxser;
@Autowired
SalaryGrantDetailsService sser;

@RequestMapping("right_list")
    public  String right_list_selectAll(Map map,
                                        @RequestParam(defaultValue = "1", required = false) Integer startPage,
                                        @RequestParam(defaultValue = "5", required = false) Integer PageSize){
    PageHelper.startPage(startPage, PageSize); //使用分页插件
    List<Map> config = qxser.config_majorSelectALL();
    PageInfo pageInfo = new PageInfo(config, 5); //保存分页信息
    map.put("pageInfo", pageInfo);
    map.put("config", config);
    return "/page/power/right_list.html";
}
//条转到添加页面
@RequestMapping("right_add")
public String right_add( Map map){
    List<ConfigMajorKind> configMajorKinds = sser.config_major_kindSelect();
    map.put("configMajorKinds", configMajorKinds);

    return "/page/power/right_add.html";
}
//添加
    @RequestMapping("right_add2")
    public String right_add2(ConfigMajor c){

        jsser.right_add2_Insert(c);
        return "redirect:right_list";
    }
    //点击修改跳转的页面
    @RequestMapping("right_list_update")
    public String right_list_update(int id,Map map){
        List<ConfigMajorKind> configMajorKinds = sser.config_major_kindSelect();
        ConfigMajor configMajor = jsser.right_list_Selectone(id);
       // System.out.println(configMajor.getStatus());
        map.put("configMajorKinds", configMajorKinds);
        map.put("con", configMajor);

        return"/page/power/right_list_information.html";
    }
    @RequestMapping("right_list_update2")
    public String right_list_update2(ConfigMajor c){

        jsser.right_list_update2(c);

return "redirect:right_list";
    }


    //删除
    @RequestMapping("right_list_delete")
    public String right_list_delete(int id){
    jsser.right_list_delete(id);
    return "redirect:right_list";


    }

}
